package com.base.myproject.client.ui;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Stack;

import com.base.myproject.client.busi.BO.BaseObject;
import com.extjs.gxt.ui.client.GXT;
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
import com.extjs.gxt.ui.client.Style.SortDir;
import com.extjs.gxt.ui.client.core.DomHelper;
import com.extjs.gxt.ui.client.core.El;
import com.extjs.gxt.ui.client.core.FastMap;
import com.extjs.gxt.ui.client.data.ModelData;
import com.extjs.gxt.ui.client.data.SortInfo;
import com.extjs.gxt.ui.client.event.ColumnModelEvent;
import com.extjs.gxt.ui.client.event.EventType;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.GridEvent;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.MenuEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.js.JsArray;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.store.Record;
import com.extjs.gxt.ui.client.store.StoreEvent;
import com.extjs.gxt.ui.client.store.StoreListener;
import com.extjs.gxt.ui.client.util.Point;
import com.extjs.gxt.ui.client.widget.Component;
import com.extjs.gxt.ui.client.widget.ComponentHelper;
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
import com.extjs.gxt.ui.client.widget.grid.ColumnData;
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
import com.extjs.gxt.ui.client.widget.grid.EditorGrid;
import com.extjs.gxt.ui.client.widget.grid.Grid;
import com.extjs.gxt.ui.client.widget.grid.GridCellRenderer;
import com.extjs.gxt.ui.client.widget.grid.GridTemplates;
import com.extjs.gxt.ui.client.widget.grid.GridView;
import com.extjs.gxt.ui.client.widget.grid.GridViewConfig;
import com.extjs.gxt.ui.client.widget.menu.CheckMenuItem;
import com.extjs.gxt.ui.client.widget.menu.Menu;
import com.extjs.gxt.ui.client.widget.menu.MenuItem;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Node;
import com.google.gwt.dom.client.NodeList;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.i18n.client.NumberFormat;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.DeferredCommand;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.AbstractImagePrototype;
import com.google.gwt.user.client.ui.Widget;
/**
 * 进通过修改gxt的源程序获得效果，此类作废
 * @author zgw
 *2009-10-13 下午05:25:17
 * javazgw@gmail.com
 */
@Deprecated
public class BaseGridView extends GridView {/*
	public BaseGridView()
	{
		
	}
	


	  *//**
	   * Icons used by Grid which can be overridden as needed. s
	   *//*
	  public class GridViewImages {
	    private AbstractImagePrototype sortAsc = GXT.IMAGES.grid_sortAsc();
	    private AbstractImagePrototype sortDesc = GXT.IMAGES.grid_sortDesc();
	    private AbstractImagePrototype columns = GXT.IMAGES.grid_columns();

	    public AbstractImagePrototype getColumns() {
	      return columns;
	    }

	    public AbstractImagePrototype getSortAsc() {
	      return sortAsc;
	    }

	    public AbstractImagePrototype getSortDesc() {
	      return sortDesc;
	    }

	    public void setColumns(AbstractImagePrototype columnsIcon) {
	      this.columns = columnsIcon;
	    }

	    public void setSortAsc(AbstractImagePrototype sortAscIcon) {
	      this.sortAsc = sortAscIcon;
	    }

	    public void setSortDesc(AbstractImagePrototype sortDescIcon) {
	      this.sortDesc = sortDescIcon;
	    }
	  }

	 

	  private String cellSelector = "td.x-grid3-cell";
	  private int cellSelectorDepth = 4;
	  private Listener<ColumnModelEvent> columnListener;
	  private boolean focusEnabled = true;
	  private boolean headerDisabled;
	  private int lastViewWidth;
	  private StoreListener<ModelData> listener;
	  private Element overRow;
	  private String rowSelector = "div.x-grid3-row";
	  private int rowSelectorDepth = 10;
	  private boolean showDirtyCells = true;
	  private SortInfo sortState;

	  private boolean vbar;
	 
	 // private boolean layoutRun = false;
	  //private List<Map<String, Widget>> widgetMap = new ArrayList<Map<String, Widget>>();

	 

	 

	


	  protected String doRender(List<ColumnData> cs, List<ModelData> rows, int startRow, int colCount, boolean stripe) {
		    int last = colCount - 1;
		    String tstyle = "width:" + getTotalWidth() + "px;";

		    StringBuilder buf = new StringBuilder();

		    for (int j = 0; j < rows.size(); j++) {
		      ModelData model = (ModelData) rows.get(j);
		      Record r = ds.hasRecord(model) ? ds.getRecord(model) : null;

		      int rowIndex = (j + startRow);

		      buf.append("<div class=\"x-grid3-row ");
		    
		      if (stripe && ((rowIndex + 1) % 2 == 0)) {
		        buf.append(" x-grid3-row-alt");
		      }
		      if (showDirtyCells && r != null && r.isDirty()) {
		        buf.append(" x-grid3-dirty-row");
		      }
		      if (viewConfig != null) {
		        buf.append(" ");
		        buf.append(viewConfig.getRowStyle(model, rowIndex, ds));
		      }
		      buf.append("\" style=\"");
		      buf.append(tstyle);
		      buf.append("\"><table class=x-grid3-row-table border=0 cellspacing=0 cellpadding=0 style=\"");
		      buf.append(tstyle);
		      buf.append("\"><tbody><tr>");

		      for (int i = 0; i < colCount; i++) {
		        ColumnData c = cs.get(i);
		        c.css = c.css == null ? "" : c.css;
		        String rv = getRenderedValue(c, rowIndex, i, model, c.name);

		        String attr = c.cellAttr != null ? c.cellAttr : "";
		        String cellAttr = c.cellAttr != null ? c.cellAttr : "";

		       // buf.append("<td class=\"x-grid3-col x-grid3-cell x-grid3-td-");
		        buf.append("<td class=\"x-grid3-td-");
		        buf.append(c.id);
		        buf.append(" ");
		        buf.append(i == 0 ? "x-grid-cell-first " : (i == last ? "x-grid3-cell-last " : ""));
		        if (c.css != null) {
		          buf.append(c.css);
		        }
		        if (showDirtyCells && r != null && r.getChanges().containsKey(c.id)) {
		          buf.append(" x-grid3-dirty-cell");
		        }
		        buf.append("\" style=\"");
		        buf.append(c.style);
		        buf.append("\" tabIndex=0 ");
		        buf.append(cellAttr);
		        buf.append("><div class=\"x-grid3-cell-inner x-grid3-col-");
		        //buf.append("><div class=\"x-grid3-col-");
		        buf.append(c.id);
		        buf.append("\" ");
		        buf.append(attr);
		        buf.append(">");
		        buf.append(rv);
		        buf.append("</div></td>");
		      }

		      buf.append("</tr>");
		      buf.append((enableRowBody
		          ? ("<tr class=x-grid3-row-body-tr style=\"\"><td colspan=" + colCount + " class=x-grid3-body-cell tabIndex=0><div class=x-grid3-row-body>${body}</div></td></tr>")
		          : ""));
		      buf.append("</tbody></table></div>");
		    }

		   
		    return buf.toString();
		  }

	

	  *//**
	   * Initializes the data.
	   * 
	   * @param ds the data store
	   * @param cm the column model
	   *//*
	  @SuppressWarnings("unchecked")
	  protected void initData(ListStore ds, ColumnModel cm) {
	    if (this.ds != null) {
	      this.ds.removeStoreListener(listener);
	    }
	    if (ds != null) {
	      ds.addStoreListener(listener);
	    }
	    this.ds = ds;

	    if (this.cm != null) {
	      this.cm.removeListener(Events.HiddenChange, columnListener);
	      this.cm.removeListener(Events.HeaderChange, columnListener);
	      this.cm.removeListener(Events.WidthChange, columnListener);
	    }
	    if (cm != null) {
	      cm.addListener(Events.HiddenChange, columnListener);
	      cm.addListener(Events.HeaderChange, columnListener);
	      cm.addListener(Events.WidthChange, columnListener);
	    }
	    this.cm = cm;
	  }

	  protected void initElements() {
	    NodeList<Node> cs = grid.getElement().getFirstChild().getChildNodes();

	    el = grid.el().firstChild();

	    mainWrap = new El((com.google.gwt.user.client.Element) cs.getItem(0));
	    mainHd = mainWrap.firstChild();

	    if (grid.isHideHeaders()) {
	      mainHd.setVisible(false);
	    }

	    innerHd = mainHd.firstChild();

	    scroller = mainWrap.getChild(1);
	    scroller.addEventsSunk(Event.ONSCROLL);

	    if (forceFit) {
	      scroller.setStyleAttribute("overflowX", "hidden");
	    }

	    mainBody = scroller.firstChild();
	    focusEl = scroller.getChild(1);
	    grid.swallowEvent(Events.OnClick, focusEl.dom, true);
	  }

	

	

	 

	 




	  private void restrictMenu(Menu columns) {
	    int count = 0;
	    for (int i = 0, len = cm.getColumnCount(); i < len; i++) {
	      if (!cm.isHidden(i) && !cm.isFixed(i)) {
	        count++;
	      }
	    }

	    if (count == 1) {
	      for (Component item : columns.getItems()) {
	        CheckMenuItem ci = (CheckMenuItem) item;
	        if (ci.isChecked()) {
	          ci.disable();
	        }
	      }
	    } else {
	      for (Component item : columns.getItems()) {
	        item.enable();
	      }
	    }
	  }



	 
	
*/}
